# Contributor: Marian Buschsieweke <marian.buschsieweke@ovgu.de>
# Maintainer: Aiden Grossman <agrossman154@yahoo.com>
pkgname=vtk
pkgver=9.2.6
pkgrel=4
pkgdesc="A software system for 3D computer graphics, image processing and visualization"
url="https://vtk.org/"
# s390x blocked by netcdf
arch="all !s390x"
license="BSD-3-Clause"
depends_dev="
	boost-dev
	curl-dev
	doxygen
	ffmpeg-dev
	gdal-dev
	glew-dev
	hdf5-dev
	jpeg-dev
	libaec-dev
	libpng-dev
	libxml2-dev
	netcdf-dev
	openmpi-dev
	pdal-dev
	proj-dev
	qt5-qtbase-dev
	qt5-qttools-dev
	qt5-qtx11extras-dev
	sqlite-dev
	tk-dev
	unixodbc-dev
	zlib-dev
	"
makedepends="$depends_dev
	cmake
	samurai
	"
checkdepends="
	xvfb-run
	mesa-dri-gallium
	"
subpackages="$pkgname-doc $pkgname-dev"
source="
	https://www.vtk.org/files/release/${pkgver%.*}/VTK-$pkgver.tar.gz
	https://www.vtk.org/files/release/${pkgver%.*}/VTKData-$pkgver.tar.gz
	https://www.vtk.org/files/release/${pkgver%.*}/VTKLargeData-$pkgver.tar.gz
	disable-tests.patch
	include-cstdint.patch
	lfs64.patch
	unistd.patch
	"
builddir="$srcdir/VTK-$pkgver"

build() {
	CXXFLAGS="$CXXFLAGS -DLOGURU_STACKTRACES=0" \
	cmake -B build -G Ninja \
		-Wno-dev \
		-DCMAKE_SKIP_INSTALL_RPATH=ON \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DVTK_USE_LARGE_DATA=ON \
		-DVTK_PYTHON_VERSION="3" \
		-DVTK_CUSTOM_LIBRARY_SUFFIX="" \
		-DCMAKE_BUILD_TYPE=Release \
		-DVTK_MODULE_USE_EXTERNAL_VTK_hdf5=ON \
		-DVTK_MODULE_USE_EXTERNAL_VTK_libproj=ON \
		-DVTK_MODULE_USE_EXTERNAL_VTK_netcdf=ON \
		-DVTK_BUILD_TESTING="$(want_check && echo ON || echo OFF)"
	cmake --build build
}

check() {
	xvfb-run -a ctest -a -j $JOBS \
		--rerun-failed \
		--output-on-failure \
		-E 'FiltersCoreCxx-TestFeatureEdges' \
		--test-dir ./build
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
f2328caae959d583299b7fd57205f3dd76f87c8c1ee78653e85d44cab085295bf7bf88b3f6a2b960a57df96ccb32049337ebccb067ecde6d84d25eda636196bc  VTK-9.2.6.tar.gz
5c5f2b365777733180a63daff224da7055e1c2911eb5e4efda26e38b9ac01cb8e886cf7e71c45ac83347642caf1786e72bb469c22954ffbbb6e2c317fc6b4080  VTKData-9.2.6.tar.gz
f0b71baa4e346746e186c6a0cc93588d227b91cd4993ee6afe15708006250b0b3aa9447822845e01432728c12af56c68a213831b6dc809807ca341ff6912f55f  VTKLargeData-9.2.6.tar.gz
53dc8a9f9680bd124399161f6703aa2a4e1ce3460b237de1858e2abff128628769a08484f927a4d0aa87c26abd279025391c6206751a68d4ba8dc7b0ef96e1d1  disable-tests.patch
7f05d7815f5c99e00af1fe891fd9251e353271cc53fc72a8463a06da23e2614cb80e331aac566608868d01ada74672f25217c7bfe6d645218256a0ed9e4b54dd  include-cstdint.patch
ec8d73f9fa425c4ad4caa9031e656ecb2d89db7ea31df0fa029ef45dc832b76557b4fef306d2c40ca8694b4bad8f37c0c8672face34728f1bcc764c6df039c6b  lfs64.patch
0f9135c421344f789db64ad46f6acd452214de8f1d4696dea3cd1d3517d0057d277a4d01e82804ffb7db086fd7527e511baa1b24a38826aec5c44872610ca0cb  unistd.patch
"
